package com.iocup.keybastion.authentication.authenticator;


import com.github.sd4324530.jtuple.Tuple2;
import com.iocup.keybastion.context.WebContextHolder;
import com.iocup.keybastion.core.profile.UserProfile;
import com.iocup.keybastion.core.session.Session;
import com.pine.sunflower.core.Typer;

import java.util.Optional;

/**
 *  登录认证器
 * @author xyjxust
 * @create 2022/3/8
 **/
public interface Authenticator<T extends LoginCredentials> extends Typer {

    /**
     * 获取认证凭证
     * @param webContextHolder web上下文
     * @return
     */
    Optional<T> getCredentials(WebContextHolder webContextHolder);

    /**
     * 通过凭证获取用户信息
     * @param credentials 凭证信息
     * @return
     */
    Optional<Tuple2<UserProfile, Session>> authenticate(T credentials, WebContextHolder webContextHolder);

}
